package com.event.binlog.task;


import com.event.binlog.iface.IDistributedLockService;
import com.event.common.constant.BinlogRowEventConst;
import com.github.shyiko.mysql.binlog.BinaryLogClient;

public class KeepAliveTask implements Runnable{

    private BinaryLogClient client;

    private IDistributedLockService distributedLockService;

    private int renewalTime;

    public KeepAliveTask(BinaryLogClient client, IDistributedLockService distributedLockService,int renewalTime){
        this.client = client;
        this.distributedLockService = distributedLockService;
        this.renewalTime = renewalTime;
    }

    @Override
    public void run() {
        if(client.isKeepAlive()){
            distributedLockService.renewal(BinlogRowEventConst.EVENT_LCOK,renewalTime);
        }
    }
}
